import json


class Protocol(object):
    # @staticmethod
    # def json_update_ip(ip=None):
    #     msg_dic = {
    #         "action": "update_ip",
    #         "ip": ip
    #     }
    #     return json.dumps(msg_dic)

    @staticmethod
    def json_update_order_info(order_info=None, timestamp="0"):
        msg_dic = {
            "action": "update_order_info",
            "order_info": order_info,
            "timestamp": timestamp
        }
        return json.dumps(msg_dic)

    @staticmethod
    def json_update_topo_info(topo_info=None, timestamp="0"):
        msg_dic = {
            "action": "update_topo_info",
            "topo_info": topo_info,
            "timestamp": timestamp
        }
        return json.dumps(msg_dic)

    @staticmethod
    def json_transfer_useful_info(source_ip=None, filename=None, filesize="0", timestamp="0"):
        msg_dic = {
            "action": "transfer_useful_info",
            "source_ip": source_ip,
            "filename": filename,
            "filesize": filesize,
            "timestamp": timestamp
        }
        return json.dumps(msg_dic)

    @staticmethod
    def json_wakeup(timestamp="0"):
        msg_dic = {
            "action": "wakeup",
            "timestamp": timestamp
        }
        return json.dumps(msg_dic)

    # @staticmethod
    # def json_move(filename=None, filesize="0"):
    #     msg_dic = {
    #         "action": "move",
    #         "filename": filename,
    #         "filesize": filesize
    #     }
    #     return json.dumps(msg_dic)